/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package guessflags;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author Administrator
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {

            String insert1 = "INSERT INTO world VALUES (1,'Canada','32805041', '385503','Ottawa','English')";
            String insert2 = "INSERT INTO world VALUES (2,'Brazil','186112794', '3286488', 'Brasilia','Portuguese')";
            String insert3 = "INSERT INTO world VALUES (3,'North Korea','22912177', '46541', 'Pyongyang','Korean')";
            String insert4 = "INSERT INTO world VALUES (4,'South Korea ','48422644', '38023', 'Seoul','Korean')";
            String insert5 = "INSERT INTO world VALUES (5,'Mongolia','2791272', '603909', 'Ulaanbaatar','Khalkha Mongol,Turkic,Russian')";
            String insert6 = "INSERT INTO world VALUES (6,'United States Of America','295734134', '3718711', 'Washington DC','English')";
            String insert7 = "INSERT INTO world VALUES (7,'Lithuania','3596617', '25174', 'Vilnius','Lithuanian')";
            String insert8 = "INSERT INTO world VALUES (8,'Turkey','301384', '69660559', 'Ankara','Turkish')";
            String insert9 = "INSERT INTO world VALUES (9,'England','60441457', '94526', 'London','English')";
            String insert10 = "INSERT INTO world VALUES (10,'China','1350000000', '9600000', 'Beijing','Chinese')";
            GuessFlagsGame frame = new GuessFlagsGame();
            frame.setVisible(true);
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            String URL = "jdbc:mysql://194.47.47.18:3306/DA5221_GRP4?user=DA5221_GRP4&password=Fu393m";


            Connection c = DriverManager.getConnection(URL);
            Statement st = c.createStatement();
            st.executeUpdate(insert1);
            st.executeUpdate(insert2);
            st.executeUpdate(insert3);
            st.executeUpdate(insert4);
            st.executeUpdate(insert5);
            st.executeUpdate(insert6);
            st.executeUpdate(insert7);
            st.executeUpdate(insert8);
            st.executeUpdate(insert9);
            st.executeUpdate(insert10);

            ResultSet rs = st.executeQuery("SELECT"
                    + " * FROM world");

            while (rs.next()) {
                int nbr = rs.getInt("population");
                String name = rs.getString("country");
                System.out.println("country: " + name + " and nbr " + nbr);
            }
            c.close();


        } catch (Exception e) {
            e.printStackTrace();
            System.err.println("ERROR: " + e);
        }
    }
}
// TODO code application logic here

